﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:RingSlice"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Common="using:RingSlice.Common"
    x:Class="RingSlice.MainPage"
    mc:Ignorable="d">
    <Page.Resources>
        <Common:NegativeConverter x:Key="NegativeConverter"/>
    </Page.Resources>

    <Page.DataContext>
        <Common:ViewModel/>
    </Page.DataContext>

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        <Grid Width="400" Height="400">

            <!-- ring -->
            <Common:RingSlice InnerRadius="100" Radius="150" Fill="#FFEC288A" StartAngle="0" EndAngle="{Binding Angle}"  />

            <!-- thing -->
            <Grid RenderTransformOrigin="0.5,0.5">
                <Grid.RenderTransform>
                    <CompositeTransform Rotation="{Binding Angle}"/>
                </Grid.RenderTransform>
                <Path Width="60" Height="100" VerticalAlignment="Top" HorizontalAlignment="Center" Stretch="Fill" Fill="#FFFFFFFF" Data="F1 M 254,99C 298.735,99 335,135.265 335,180C 335,224.735 253,349.667 253,349.667C 253,349.667 173,224.735 173,180C 173,135.265 209.265,99 254,99 Z "/>
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" FontSize="18" Foreground="Black" 
                    RenderTransformOrigin="0.5,0.5">
                    <TextBlock.Inlines>
                        <Run Text="{Binding Value}" /> m
                    </TextBlock.Inlines>
                    <TextBlock.RenderTransform>
                        <CompositeTransform TranslateY="17" Rotation="{Binding Angle, Converter={StaticResource NegativeConverter}}"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
            </Grid>

            <!-- touch grid -->
            <Grid Background="Transparent" ManipulationMode="TranslateX,TranslateY" ManipulationDelta="Grid_ManipulationDelta" >
                <Grid.Clip>
                    <RectangleGeometry Rect="150,0,100,100">
                        <RectangleGeometry.Transform>
                            <CompositeTransform Rotation="{Binding Angle}" CenterX="200" CenterY="200" />
                        </RectangleGeometry.Transform>
                    </RectangleGeometry>
                </Grid.Clip>
            </Grid>

            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32" Foreground="Gray">
        <Run Foreground="White" Text="12" />h <Run Foreground="White" Text="{Binding Value}" />m
            </TextBlock>

        </Grid>

        </Grid>
</Page>